package com.crecheng.shop.Manage;

import com.crecheng.shop.DAO.StarData;
import com.crecheng.shop.util.ConSQL;
import com.crecheng.shop.util.ListUtil;
import org.thymeleaf.util.ListUtils;

import java.util.List;

public final class StarManage {
    public static List<StarData> getAll(){
        return ConSQL.select(StarData.class);
    }

    public static List<StarData> get(String other){
        return ConSQL.select(StarData.class,other);
    }

    public static StarData get(int id){
        var d=get("id="+id);
        return ListUtil.first(d);
    }

    public static List<StarData> getByUser(int uid){
        return get("uid="+uid);
    }

    public static boolean add(StarData data){
        return ConSQL.insert(StarData.class,data)>0;
    }

    public static boolean del(int id){
        return ConSQL.delete(StarData.class,"id="+id)>0;
    }

    public static int delByUser(int uid){
        return ConSQL.delete(StarData.class,"uid="+uid);
    }

    public static boolean del(StarData data){
        return del(data.getId());
    }
}
